<template>
	<view>
		<!-- 自定义导航栏 -->
		<uni-nav-bar :statusBar="true" rightText="发布" left-icon="arrowleft" @clickLeft="back"
		@clickRight="submit"> 
			<view class="nav" @tap="changelook">
				{{yinsi}}
				<view class="iconfont icon-xialazhankai" style="font-size: 25upx;"></view>
			</view>
		</uni-nav-bar>
		<!-- 多行输入框 -->
		<view class="uni-textarea">
		    <textarea v-model="text" placeholder="说一句话吧~" />			
		</view>
		<!-- 上传多图 -->
		<upload-images @uploud="uploud"></upload-images>	
		<!-- 弹框 -->
		<s-popup position="center" v-model="visible" :maskOpacity="0.3" :maskClose="false">
		  <view class="gonggao">
			  <view class="u-f-ajc">
				  <image src="../../static/common/addinput.png" mode=""></image>
			  </view>
			  <view class="txt">
				  <view>1、涉及黄色,政治,广告及骚扰信息</view>
				  <view>2、涉及人身攻击</view>
				  <view>3、留联系方式,透露他人隐私</view>
				  <view>一经核实将被封禁,情节严重者永久封禁</view>
			  </view>
			  <button type="primary" @tap="close">朕知道了</button>
		  </view>
		</s-popup>
	</view>
</template>

<script>
	let changelook = ['所有人可见', '仅自己可见']
	import uniNavBar from "../../components/uni-nav-bar/uni-nav-bar.vue"
	import uploadImages from "../../components/common/upload-images.vue"
	import sPopup from '../../components/s-popup/index.vue'
	export default {
		components:{
			uniNavBar,
			uploadImages,
			sPopup
		},
		data() {
			return {
				isget:false,
				visible: true,
				yinsi:"所有人可见",
				text:'',
				imglist:[]
			}
		},
		onBackPress(){
			if(!this.text && this.imglist.length<1){
				return;
			}
			if(!this.isget){
			    this.save()
			    return true;
			}
		},
		methods: {
			//保存为草稿
			save(){
				uni.showModal({
					content:'是否要保存为草稿',
					cancelText:'不保存',
					confirmText:'保存',
					success:res=>{
						if(res.confirm){
							console.log('保存')
						}else{
							console.log('不保存')
						}
						this.isget=true
						uni.navigateBack({
							delta:1
						})
					}
				})
			},
			//返回
			back(){
				uni.navigateBack({
					delta:1
				})
			},
			//发布
			submit(){
				console.log('发布')
			},
			//隐私
			changelook(){
				uni.showActionSheet({
				    itemList: changelook,
				    success: res=> {
						this.yinsi = changelook[res.tapIndex]
						
				    }
				});
			},
			uploud(arr){
				this.imglist = arr
				console.log(this.imglist)
			},
			close(){
				this.visible = false
			}
		}
	}
</script>

<style>
.nav {
	margin: 0 auto;
	display: flex;
	justify-content: center;
	align-items: center;
}
.uni-textarea {
	border:1upx solid #EEEEEE
}
.gonggao {
	display: inline-block;
	width: 650upx;
}
.gonggao image {
	padding-left: 15%;
	padding: 0 auto;
	width: 70%;
	margin-bottom: 20upx;
}
.gonggao button {
	margin-top: 20upx;
	width: 80%;
	background: #FFE934;
	color: #171606;
}
/* .txt {
	text-align: center;
} */
</style>
